<template>
    <div>
        <div class="add_title">请填写要扫码签到的就诊人信息</div>
        <div class="add_cell">
            <div class="add_cell_left">
                <span>*</span>
                姓名
            </div>
            <div class="add_cell_right">
                <input type="text" placeholder="请输入姓名" v-model="name" />
            </div>
        </div>
        <div class="add_cell">
            <div class="add_cell_left">
                <span>*</span>
                身份证号
            </div>
            <div class="add_cell_right">
                <input type="text" placeholder="请输入身份证号" v-model="idNo" />
            </div>
        </div>
        <div class="page_btn" @click="goSign">确定</div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            name: "",
            idNo: "",
            reg: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
        }
    },
    created() {

    },
    methods: {
        goSign() {
            if (!this.name) {
                alert("姓名不能为空！");
                return;
            }
            if (!/^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}([0-9]|x|X)$/.test(this.idNo)) {
                alert("身份证格式不对！");
                return;
            }

            //获取性别
            var info = {
                name: this.name,
                sex: 1
            }
            if (parseInt(this.idNo.substr(16, 1)) % 2 === 1) {
                info.sex == 1
            } else {
                info.sex = 2
            }
            window.localStorage.setItem("signUserInfo", JSON.stringify(info));
            this.$router.push({
                path: "/sign_in_index",
                query: {
                    idNo: this.idNo,
                    deptQrCode: this.$route.query.deptId
                }
            })
        },
    },
}
</script>
<style lang="less">
.add_title {
    line-height: 3.125rem;
    font-size: 1.0625rem;
    text-align: center;
}

.add_cell {
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 16px;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e7ecf5;

    &_left {
        span {
            color: red;
        }
    }

    &_right {
        input {
            border: none;
            text-align: right;
            font-size: 1rem;
            outline: none;
        }

        .code {
            border: 1px solid #448eff;
            border-radius: 3px;
            padding: 3px 10px;
            color: #448eff;
            margin-left: 10px;
            font-size: 15px;
        }

        .code1 {
            border: 1px solid #a4adbe;
            border-radius: 3px;
            padding: 3px 10px;
            color: #a4adbe;
            margin-left: 10px;
            font-size: 15px;
        }
    }
}
</style>
